package v1

import (
	"gitee.com/liangziyisheng/caas-platform-mc/internal/consts"
	"gitee.com/liangziyisheng/caas-platform-mc/internal/model/do"
	"gitee.com/liangziyisheng/caas-platform-mc/internal/model/entity"

	"github.com/gogf/gf/v2/frame/g"
)

type ListReq struct {
	g.Meta  `path:"/regions" tags:"行政区域" method:"get" summary:"区域列表"`
	Country string `json:"country"`
}
type ListRes struct {
	g.Meta `mime:"application/json"`
	Data   []*RegionTree `json:"data"`
}

type RegionTree struct {
	Id       int64         `json:"id"     description:""`
	Code     string        `json:"code"  description:"编码"`
	Parent   string        `json:"parent" description:"上级编码"`
	Level    uint          `json:"level"  description:"层级:1国家,2省州,3城市,4区县"`
	Name     string        `json:"name"   description:"名称"`
	Children []*RegionTree `json:"children" description:"子节点"`
}

type AddReq struct {
	g.Meta  `path:"/regions" tags:"行政区域" method:"post" summary:"添加区域"`
	Code    string `json:"code"   v:"required"`
	Parent  string `json:"parent"`
	Level   uint   `json:"level"  v:"required|min:1"`
	Name    string `json:"name"   v:"required"`
	Country string `json:"country" v:"required" description:"国家编码"`
}
type AddRes struct {
	g.Meta `mime:"application/json"`
	Id     int64 `json:"id"`
}

type UpdateReq struct {
	g.Meta `path:"/regions/{id}" tags:"行政区域" method:"put" summary:"更新区域"`
	Id     int64  `query:"id" v:"required|min:1" description:"区域ID"`
	Name   string `json:"name"`
}
type UpdateRes struct {
	g.Meta `mime:"application/json"`
	Rows   int64 `json:"rows"`
}

type DeleteReq struct {
	g.Meta `path:"/regions/{id}" tags:"行政区域" method:"delete" summary:"删除区域"`
	Id     int64 `query:"id" v:"required|min:1"`
}
type DeleteRes struct {
	g.Meta `mime:"application/json"`
	Rows   int64 `json:"rows"`
}
type CountriesReq struct {
	g.Meta `path:"/regions/countries" tags:"行政区域" method:"get" summary:"国家列表"`
}
type CountriesRes struct {
	g.Meta `mime:"application/json"`
	Data   []consts.DdicInfo1 `json:"data" description:"国家列表"`
}

// input and output struct
type ListInput struct {
	Country string `json:"country"  description:"编码"`
}
type ListOutput struct {
	Data []entity.Region `json:"data"`
}
type AddInput struct {
	do.Region
}
type AddOutput struct {
	Id int64 `json:"id"`
}
type UpdateInput struct {
	do.Region
}
type UpdateOutput struct {
	Rows int64 `json:"rows"`
}
type DeleteInput struct {
	Id int64 `json:"id" description:"区域ID"`
}
type DeleteOutput struct {
	Rows int64 `json:"rows"`
}
